cmake_minimum_required(VERSION 3.0.2)
project(bosch_locator_bridge)
find_package(catkin REQUIRED COMPONENTS
    geometry_msgs
    message_generation
    nav_msgs
    pcl_conversions
    roscpp
    sensor_msgs
    std_msgs
    std_srvs
    tf2
    tf2_geometry_msgs
    tf2_ros
)

find_package(Poco REQUIRED COMPONENTS Foundation Net JSON)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# under melodic, we get a deprecation warning from a ROS include
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-deprecated-declarations")

add_message_files(
  DIRECTORY
  msg
  FILES
    ClientControlMode.msg
    ClientExpandMapOverwriteZoneInformation.msg
    ClientExpandMapVisualization.msg
    ClientGlobalAlignLandmarkObservationNotice.msg
    ClientGlobalAlignLandmarkVisualizationInformation.msg
    ClientGlobalAlignVisualization.msg
    ClientLocalizationPose.msg
    ClientLocalizationVisualization.msg
    ClientMapVisualization.msg
    ClientRecordingVisualization.msg
    ServerMapZone.msg
    point2d.msg
)

add_service_files(
  FILES
    ClientConfigGetEntry.srv
    ClientExpandMapEnable.srv
    ClientMapList.srv
    ClientMapSend.srv
    ClientMapSet.srv
    ClientMapStart.srv
    ClientRecordingSetCurrentPose.srv
    ClientSetSeed.srv
    StartRecording.srv
    ServerMapGetImageWithResolution.srv
    ServerMapList.srv
    AddLandMark.srv
    StartVisualRecording.srv
    ChangeLaser.srv
    ServerMapDelete.srv
    ServerMapGetlmage.srv
    ServerMapRename.srv
    serverMapGetMapThumbnail.srv
    ClientManualAlignSet.srv
    serverMapAddZone.srv
)

generate_messages(
  DEPENDENCIES
    geometry_msgs
    nav_msgs
    sensor_msgs
    std_msgs
    bosch_locator_bridge
)

catkin_package(
  CATKIN_DEPENDS
    geometry_msgs
    message_runtime
    nav_msgs
    pcl_conversions
    roscpp
    sensor_msgs
    std_msgs
    std_srvs
    tf2
    tf2_geometry_msgs
    tf2_ros
)

include_directories(
  ${catkin_INCLUDE_DIRS}
  include/${PROJECT_NAME}
)

add_executable(${PROJECT_NAME}_node
  src/main.cpp
  src/locator_bridge_node.cpp
  src/sending_interface.cpp
  src/receiving_interface.cpp
  src/rosmsgs_datagram_converter.cpp
  src/locator_rpc_interface.cpp)
set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_node
  ${catkin_LIBRARIES}
  Poco::Foundation
  Poco::JSON
  Poco::Net
)

add_executable(${PROJECT_NAME}_server_node
  src/locator_rpc_interface.cpp
  src/rosmsgs_datagram_converter.cpp
  src/server/server_bridge_node.cpp
  src/server/server_main.cpp)
set_target_properties(${PROJECT_NAME}_server_node PROPERTIES OUTPUT_NAME server_node PREFIX "")
add_dependencies(${PROJECT_NAME}_server_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_server_node
  ${catkin_LIBRARIES}
  Poco::Foundation
  Poco::JSON
  Poco::Net
)

# # 设置安装目录 deb打包安装
# set(CMAKE_INSTALL_PREFIX "/home/kybot/kybot_ws/install")

# install(TARGETS ${PROJECT_NAME}_node
#         RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}
# )

# install(TARGETS ${PROJECT_NAME}_server_node
#         RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}_server_node
# )

# install(FILES config/locator_bridge_localization.rviz config/locator_bridge_map_creation.rviz config/locator_bridge_visual_recording.rviz
#         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/config
# )
# install(FILES launch/bridge.launch
#         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/launch
# )

# install(FILES launch/server_bridge.launch
#         DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/launch
# )
# 设置安装目录
set(CMAKE_INSTALL_PREFIX "/home/kybot/kybot_ws/install")
install(TARGETS ${PROJECT_NAME}_node ${PROJECT_NAME}_server_node
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
#启动和配置文件目录
install(DIRECTORY launch config 
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}
)